function changeServiceType2() {
    var serviceType2 = $("#serviceType2>option:selected").text(); //故障分类
    if (serviceType2 == "现场检测") {
        $("#speciallyHD").attr("checked", true);
    } else if (serviceType2 == "维保检测") {
        $("#speciallyHD").attr("checked", true);
    } else if (serviceType2 == "技术支持") {
        $("#speciallyHD").attr("checked", true);
    } else {
        //如果，没有选择是否特批，故障分类二也不是TMS，则取消，否则被取消
        var errorType2 = $("#errorType2>option:selected").text(); //故障分类
        if ($("#specially").is(':checked')) {  //勾选了特批，
            $("#speciallyHD").attr("checked", true);
        } else if (errorType2 == 'TMS') {
            $("#speciallyHD").attr("checked", true);
        } else {
            $("#speciallyHD").removeAttr("checked");
        }
    }
}

function changeErrorType2() {
    var errorType2 = $("#errorType2>option:selected").text(); //故障分类
    if (errorType2 == 'TMS') {
        $("#speciallyHD").attr("checked", true);
    } else {
        var serviceType2 = $("#serviceType2>option:selected").text(); //故障分类
        if (serviceType2 == "现场检测") {
            $("#speciallyHD").attr("checked", true);
        } else if (serviceType2 == "维保检测") {
            $("#speciallyHD").attr("checked", true);
        } else if (serviceType2 == "技术支持") {
            $("#speciallyHD").attr("checked", true);
        } else {
            //如果，没有选择是否特批，故障分类二也不是TMS，则取消，否则被取消
            if ($("#specially").is(':checked')) {  //勾选了特批，
                $("#speciallyHD").attr("checked", true);
            } else {
                $("#speciallyHD").removeAttr("checked");
            }
        }
    }
}


function refresh() {
    var phone = $("#phone").val();
    if (null == phone || "" == phone) {
        top.window.tip("请填写联系人电话");
    } else {
        $.ajax({
            url: "cbsServiceController.do?getInformation",
            data: {
                "phone": phone
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                if (data.success) {
                    $("#email").val(data.attributes['email']);
                    $("#contactName").val(data.attributes['contactName']);
                    $("#level").text(data.attributes['level']);
                    $("#belongCinema").text("提示：");
                    $("#fullAddress").text(
                        "该用户所属影院：" + data.attributes['belongCinema']
                        + "。影城地址：" + data.attributes['fullAddress']);
                } else {
                    $("#email").val("");
                    $("#contactName").val("");
                    $("#level").text("");
                    $("#belongCinema").text("");
                    $("#fullAddress").text("");
                }
            }
        });
    }
}

//根据设备序列号获取设备信息
function refreshProjector() {
    var sn = $("#sn").val();
    if ("" == sn || null == sn) {
        top.window.tip("请填写设备序列号");
    } else {
        /*限制不是服务器的设备*/
        $.ajax({
            url: "cbsServiceController.do?dontService",
            data: {
                "sn": sn
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                /*不是服务器的设备*/
                if (!data.success) {

                    $.ajax({
                        url: "cbsServiceController.do?getProjector",
                        data: {
                            "sn": sn
                        },
                        cache: false,
                        dataType: 'json',
                        type: 'POST',
                        success: function (data) {
                            if (data.success) {

                                /*设备信息*/
                                var projectorlist = data.attributes['projectorlist'];

                                projectorlist.forEach(function (item) {
                                    $("#snId").text(item.id);
                                    $("#bp").text(item.BpNo);
                                    $("#typeDesc").text(item.type_desc);
                                    $("#serverState").text(item.serviceState);
                                    $("#isNormal").text(item.isNormal);
                                    $("#topItemSn").text(item.type);
                                    $("#remarks").text(item.remarks);
                                    $("#exceptionReason").text(item.exceptionReason != null ? item.exceptionReason : "");
                                    $("#installDate").text(item.INSTALL_DATE);
                                    $("#warranty_begin_date").text(item.warrantyBeginDate);
                                    $("#repair_end_date").text(item.REPAIR_END_DATE);
                                    $("#baoxiuqi").text(item.inReparirDateVal);
                                    $("#laserreconstructiontype").text(item.laserreconstructiontype != null ? item.laserreconstructiontype : "");
                                    $("#shortname").text(item.shortname != null ? item.shortname : "");
                                    /*软件版本信息*/
                                    $("#vcreate_date").text(item.vcreate_date);
                                    $("#v1").text(item.v1);
                                    $("#v2").text(item.v2);
                                    $("#esitemDesc").text(item.esitemDesc != null ? item.esitemDesc : "");
                                });

                                var cinemalist = data.attributes['cinemalist'];
                                cinemalist.forEach(function (item) {
                                    $("#zyCinemaName").val(item.zyCinemaName);
                                    $("#province").val(item.zyCinemaProvince);
                                    $("#zyCinemaAddress").val(item.zyCinemaAddress);
                                    loadCity(item.zyCinemaCity);
                                });

                                /*sla信息*/
                                var slaList1 = data.attributes['slaList1'];
                                $("#slasupplement").text('');
                                slaList1.forEach(function (item) {
                                    $("#slaREPAIR_END_DATE").text(item.REPAIR_END_DATE);
                                    $("#slawarranty_begin_date").text(item.warranty_begin_date);
                                    $("#slashortname").text(item.shortname);
                                    $("#repairType").text(item.repairType);
                                    $("#slasum").text(item.s1);
                                    /*年度巡检*/
                                    $("#s2").text(item.s2);
                                    /*工程师级别要求*/
                                    $("#s3").text(item.s3);
                                    /*光路清洁*/
                                    $("#s4").text(item.s4);
                                    /*是否含硬盘维修*/
                                    $("#slaservice_commitment").text(item.SERVICECOMMITMENT);
                                    $("#slasupplement").text(item.supplement);
                                });
                                //显示当前生效的SLA信息，并且指向SLA增项后的信息标签后，弹框显示所有SLA的标准项列表。
                                var cbsContractList = data.attributes['cbsContractList'];
                                var html = "";
                                $("#sla").html('');
                                html += "<tr><th style='width: 200px'>服务条款</th><th>标准说明</th></tr>";
                                cbsContractList.forEach(function (item) {
                                    html += "<tr><td>" + item.serviceName + "</td><td>" + item.description + "</td></tr>";
                                });
                                $('#sla').append(html);

                                /*设备相关历史*/
                                var cbsServiceList = data.attributes['cbsservicelist'];
                                $("#span1").text("设备相关历史(" + cbsServiceList.length + ")");
                                var i = 1;
                                $('#cbsservicelist').empty();
                                cbsServiceList.forEach(function (item) {
                                    if (i < 6) {
                                        i++;
                                        var newRow3 = '<tr id="newP3" >' +
                                            '<td><a href="#" style="color:blue;text-decoration:underline;" onclick="cbsServiceDetials(\'' + item.id + '\',\'' + item.code + '\')">' + item.code + '</a></td>' +
                                            '<td>' + ((item.t1name == null) ? "" : (item.t1name + '>>')) + ((item.t2name == null) ? "" : item.t2name) + '</td>' +
                                            '<td>' + ((item.e1name == null) ? "" : (item.e1name + '>>')) + ((item.e2name == null) ? "" : item.e2name) + '</td>' +
                                            '<td>' + ((item.sta == null) ? "" : item.sta) + '</td>' +
                                            '<td>' + ((item.shortname == null) ? "" : item.shortname) + '</td>' +
                                            '<td>' + ((item.speed == null) ? "" : item.speed) + '</td>' +
                                            '<td>' + ((item.create_date == null) ? "" : item.create_date) + '</td>' +
                                            '<td>' + ((item.close_time == null) ? "" : item.close_time) + '</td>' +
                                            '</tr>';
                                        $('#cbsservicelist').append(newRow3);
                                    }
                                });


                                /*影院相关历史*/
                                var cbsServiceList1 = data.attributes['cinemaMapList'];
                                $("#span2").text("影院相关历史(" + cbsServiceList1.length + ")");
                                var j = 1;
                                $('#cbsservicelist1').empty();
                                cbsServiceList1.forEach(function (item) {
                                    if (j < 6) {
                                        j++;
                                        var newRow2 = '<tr id="newP2" >' +
                                            '<td><a href="#" style="color:blue;text-decoration:underline;" onclick="cbsServiceDetials(\'' + item.id + '\',\'' + item.code + '\')">' + item.code + '</a></td>' +
                                            '<td>' + item.sn + '</td>' +
                                            '<td>' + ((item.t1name == null) ? "" : (item.t1name + '>>')) + ((item.t2name == null) ? "" : item.t2name) + '</td>' +
                                            '<td>' + ((item.sta == null) ? "" : item.sta) + '</td>' +
                                            '<td>' + ((item.shortname == null) ? "" : item.shortname) + '</td>' +
                                            '<td>' + ((item.speed == null) ? "" : item.speed) + '</td>' +
                                            '<td>' + ((item.create_date == null) ? "" : item.create_date) + '</td>' +
                                            '<td>' + ((item.close_time == null) ? "" : item.close_time) + '</td>' +
                                            '</tr>';
                                        $('#cbsservicelist1').append(newRow2);
                                    }
                                });

                                /*巡检相关历史*/
                                var zyInspectionPlanList = data.attributes['zyInspectionPlanList'];
                                $("#span3").text("巡检相关历史(" + zyInspectionPlanList.length + ")");
                                var k = 1;
                                $('#cbsservicelist2').empty();
                                zyInspectionPlanList.forEach(function (item) {
                                    if (k < 6) {
                                        k++;
                                        var newRow1 = '<tr id="newP1">' +
                                            '<td><a href="#" style="color:blue;text-decoration:underline;" onclick="planDetials(' + '\'' + item.id + '\'' + ','+'\''+item.planIds+'\''+')">' + item.planIds + '</a></td>' +
                                            '<td>' + ((item.state == null) ? "" : item.state) + '</td>' +
                                            '<td>' + ((item.dates == null) ? "" : item.dates) + '</td>' +
                                            '<td>' + ((item.time == null) ? "" : item.time) + '</td>' +
                                            '<td>' + ((item.shortname == null) ? "" : item.shortname) + '</td>' +
                                            '<td>' + ((item.eName == null) ? "" : item.eName) + '</td>' +
                                            '<td>' + ((item.beginTime == null) ? "" : item.beginTime) + '</td>' +
                                            '</tr>';
                                        $('#cbsservicelist2').append(newRow1);
                                    }
                                });
                            }
                        }
                    });
                } else {
                    if (data.msg == "S") {
                        // tip("设备序列号不存在！");
                    } else {
                        $("#sn").val("");
                        tip("设备信息处不能填写服务器的设备序列号");
                    }
                }
            }
        });
    }
}


//根据设备序列号获取服务器信息
function refreshServer() {
    var sn = $("#snServer").val();
    if (null == sn || "" == sn) {
        top.window.tip("请填写服务器信息设备序列号");
    } else {
        $.ajax({
            url: "cbsServiceController.do?dontService",
            data: {
                "sn": sn
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                /*是服务器的设备*/
                if (data.success) {
                    $.ajax({
                        url: "cbsServiceController.do?getProjector",
                        data: {
                            "sn": sn
                        },
                        cache: false,
                        dataType: 'json',
                        type: 'POST',
                        success: function (data) {
                            if (data.success) {
                                if (data.msg == "S") {
                                    $("#snServer").val("");
                                    tip("服务器序列号不存在！");
                                } else {
                                    /*设备信息*/
                                    var projectorlist = data.attributes['projectorlist'];
                                    if (null != projectorlist) {
                                        projectorlist.forEach(function (item) {
                                            $("#snServiceId").text(item.id);
                                            $("#bpServer").text(item.BpNo);
                                            $("#typeDescServer").text(item.type_desc);
                                            $("#serverStateServer").text(item.serviceState);
                                            $("#isNormalServer").text(item.isNormal);
                                            $("#topItemSnServer").text(item.type);
                                            $("#remarksServer").text(item.remarks);
                                            $("#exceptionReasonServer").text(item.exceptionReason != null ? item.exceptionReason : "");
                                            $("#installDateServer").text(item.INSTALL_DATE);
                                            $("#warranty_begin_dateServer").text(item.warrantyBeginDate);
                                            $("#repair_end_dateServer").text(item.REPAIR_END_DATE);
                                            $("#baoxiuqiService").text(item.inReparirDateVal);
                                            $("#shortnameService").text(item.shortname != null ? item.shortname : "");
                                            /*软件版本信息*/
                                            $("#vcreate_dateService").text(item.vcreate_date);
                                            $("#v1Service").text(item.v1);
                                            $("#v2Service").text(item.v2);
                                            $("#esitemDesc").text(item.esitemDesc != null ? item.esitemDesc : "");
                                        });
                                    }


                                    var cinemalist = data.attributes['cinemalist'];
                                    if (null != cinemalist) {
                                        cinemalist.forEach(function (item) {
                                            $("#zyCinemaName").val(item.zyCinemaName);
                                            $("#province").val(item.zyCinemaProvince);
                                            $("#zyCinemaAddress").val(item.zyCinemaAddress);
                                            $("#typename").val(item.cinema);
                                            loadCity(item.zyCinemaCity);
                                        });
                                    }

                                    /*sla信息*/
                                    var slaList1 = data.attributes['slaList1'];
                                    $("#slasupplement").text('');
                                    slaList1.forEach(function (item) {
                                        $("#slaREPAIR_END_DATE").text(item.REPAIR_END_DATE);
                                        $("#slawarranty_begin_date").text(item.warranty_begin_date);
                                        $("#slashortname").text(item.shortname);
                                        $("#repairType").text(item.repairType);
                                        $("#slasum").text(item.s1);
                                        /*年度巡检*/
                                        $("#s2").text(item.s2);
                                        /*工程师级别要求*/
                                        $("#s3").text(item.s3);
                                        /*光路清洁*/
                                        $("#s4").text(item.s4);
                                        /*是否含硬盘维修*/
                                        $("#slaservice_commitment").text(item.SERVICECOMMITMENT);
                                        $("#slasupplement").text(item.supplement);
                                    });

                                    /*设备相关历史*/
                                    var cbsServiceList = data.attributes['cbsservicelist'];
                                    $("#span1").text("设备相关历史(" + cbsServiceList.length + ")");
                                    var i = 1;
                                    $('#cbsservicelist').empty();
                                    cbsServiceList.forEach(function (item) {
                                        if (i < 6) {
                                            i++;
                                            var newRow3 = '<tr id="newP3" >' +
                                                '<td><a href="#" style="color:blue;text-decoration:underline;" onclick="cbsServiceDetials(\'' + item.id + '\',\'' + item.code + '\')">' + item.code + '</a></td>' +
                                                '<td>' + ((item.t1name == null) ? "" : (item.t1name + '>>')) + ((item.t2name == null) ? "" : item.t2name) + '</td>' +
                                                '<td>' + ((item.e1name == null) ? "" : (item.e1name + '>>')) + ((item.e2name == null) ? "" : item.e2name) + '</td>' +
                                                '<td>' + ((item.sta == null) ? "" : item.sta) + '</td>' +
                                                '<td>' + ((item.shortname == null) ? "" : item.shortname) + '</td>' +
                                                '<td>' + ((item.speed == null) ? "" : item.speed) + '</td>' +
                                                '<td>' + ((item.create_date == null) ? "" : item.create_date) + '</td>' +
                                                '<td>' + ((item.close_time == null) ? "" : item.close_time) + '</td>' +
                                                '</tr>';
                                            $('#cbsservicelist').append(newRow3);
                                        }
                                    });


                                    /*影院相关历史*/
                                    var cbsServiceList1 = data.attributes['cinemaMapList'];
                                    $("#span2").text("影院相关历史(" + cbsServiceList1.length + ")");
                                    var j = 1;
                                    $('#cbsservicelist1').empty();
                                    cbsServiceList1.forEach(function (item) {
                                        if (j < 6) {
                                            j++;
                                            var newRow2 = '<tr id="newP2" >' +
                                                '<td><a href="#" style="color:blue;text-decoration:underline;" onclick="cbsServiceDetials(\'' + item.id + '\',\'' + item.code + '\')">' + item.code + '</a></td>' +
                                                '<td>' + item.sn + '</td>' +
                                                '<td>' + ((item.t1name == null) ? "" : (item.t1name + '>>')) + ((item.t2name == null) ? "" : item.t2name) + '</td>' +
                                                '<td>' + ((item.sta == null) ? "" : item.sta) + '</td>' +
                                                '<td>' + ((item.shortname == null) ? "" : item.shortname) + '</td>' +
                                                '<td>' + ((item.speed == null) ? "" : item.speed) + '</td>' +
                                                '<td>' + ((item.create_date == null) ? "" : item.create_date) + '</td>' +
                                                '<td>' + ((item.close_time == null) ? "" : item.close_time) + '</td>' +
                                                '</tr>';
                                            $('#cbsservicelist1').append(newRow2);
                                        }
                                    });

                                    /*巡检相关历史*/
                                    var zyInspectionPlanList = data.attributes['zyInspectionPlanList'];
                                    $("#span3").text("巡检相关历史(" + zyInspectionPlanList.length + ")");
                                    var k = 1;
                                    $('#cbsservicelist2').empty();
                                    zyInspectionPlanList.forEach(function (item) {
                                        if (k < 6) {
                                            k++;
                                            var newRow1 = '<tr id="newP1">' +
                                                '<td><a href="#" style="color:blue;text-decoration:underline;" onclick="planDetials(' + '\'' + item.id + '\'' + ','+'\''+item.planIds+'\''+')">' + item.planIds + '</a></td>' +
                                                '<td>' + ((item.state == null) ? "" : item.state) + '</td>' +
                                                '<td>' + ((item.dates == null) ? "" : item.dates) + '</td>' +
                                                '<td>' + ((item.time == null) ? "" : item.time) + '</td>' +
                                                '<td>' + ((item.shortname == null) ? "" : item.shortname) + '</td>' +
                                                '<td>' + ((item.eName == null) ? "" : item.eName) + '</td>' +
                                                '<td>' + ((item.beginTime == null) ? "" : item.beginTime) + '</td>' +
                                                '</tr>';
                                            $('#cbsservicelist2').append(newRow1);
                                        }
                                    });
                                }
                            }
                        }
                    });
                } else {
                    $("#snServer").val("");
                    tip("该设备序列号不是服务器的设备序列号");
                }
            }
        });
    }

}


function planDetials(id, code) {
    addOneTab("巡检计划详情" + code, "zyInspectionPlanController.do?detailsOfEngineerPlan&id=" + id);
}

function cbsServiceDetials(id, code) {
    addOneTab("服务单详情" + code, "cbsServiceController.do?detail&id=" + id + "&code=" + code, "");
}

function cinemaView() {
    var name = $("#zyCinemaName").val();
    if (name == null || name == "") {
        top.window.tip("请填写影院名称");
        return false;
    } else {
        $.ajax({
            url: "cbsServiceController.do?getZyCinemaByName",
            data: {
                "name": name
            },
            cache: false,
            dataType: 'json',
            type: 'POST',
            async: false,
            success: function (data) {
                if (data.success) {
                    console.info("--影院id--" + data.obj);
                    /*影院id*/
                    addOneTab("查看影院详细", "zyCinemaController.do?goViews&id=" + data.obj, "");
                } else {
                    top.window.tip(data.msg);
                }
            }
        });
    }
}

$(function () {
    var flag = false;
    $("#specially").click(function () {
        if (flag == false) {
            $("#speciallyHD").prop("checked", true);
            flag = true;
        } else {
            $("#speciallyHD").removeAttr("checked");
            flag = false;
        }
    });
    loadCity($("#province").val());
    $("#errorphones").uploadify({
        buttonText: '上传文件',
        auto: true,
        progressData: 'speed',
        multi: true,
        height: 20,
        width: 60,
        overrideEvents: ['onDialogClose'],
        fileTypeDesc: '文件格式:',
        queueID: 'instructionfile',
        fileTypeExts: '*', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
        fileSizeLimit: '50MB',
        swf: 'plug-in/uploadify/uploadify.swf',
        uploader: 'fileUploadController.do?uploadFileService&businessKey=',
        onUploadStart: function () {
            lockmask(true, '请稍等,导入中...');
        }, onUploadSuccess: function (file, data) {
            lockmask(false);
            var fileBean = $.parseJSON(data).attributes;
            var html = '<div name="fileIda" id="attach_'+ fileBean.fileKey +'">' +
                '<input type="hidden" id="fileIdas" value="' + fileBean.fileKey + '">' +
                '<span class="color-blue" id="' + fileBean.fileKey + '">' + fileBean.name + '</span>&nbsp;&nbsp; ' +
                '<span style="cursor: pointer;" onclick=\'delFiles("' + fileBean.fileKey + '")\'>[删除]</span>' +
                '</div>';
            $("#errorphones").after(html);
            tip("上传成功！");
        }, onFallback: function () {
            tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
        }, onSelectError: function (file, errorCode, errorMsg) {
            switch (errorCode) {
                case -100:
                    tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                    break;
                case -110:
                    tip("文件 [" + file.name + "] 大小超出系统限制的50MB大小！");
                    break;
                case -120:
                    tip("文件 [" + file.name + "] 大小异常！");
                    break;
                case -130:
                    tip("文件 [" + file.name + "] 类型不正确！");
                    break;
            }
        }
    });
    $("#speciallyFiles").uploadify({
        buttonText: '上传文件',
        auto: true,
        progressData: 'speed',
        multi: true,
        height: 20,
        width: 60,
        overrideEvents: ['onDialogClose'],
        fileTypeDesc: '文件格式:',
        queueID: 'instructionfile',
        fileTypeExts: '*.*',
        fileSizeLimit: '50MB',
        swf: 'plug-in/uploadify/uploadify.swf',
        uploader: 'fileUploadController.do?uploadFileService&businessKey=',
        onUploadStart: function () {
            lockmask(true, '请稍等,导入中...');
        },onUploadSuccess: function (file, data) {
            lockmask(false);
            var fileBean = $.parseJSON(data).attributes;
            var html1 = '<div name="fileIdb" id="attach_'+ fileBean.fileKey +'">' +
                '<input type="hidden" id="fileIdbs" value="' + fileBean.fileKey + '">' +
                '<span class="color-blue" id="' + fileBean.fileKey + '">' + fileBean.name + '</span>&nbsp;&nbsp; ' +
                '<span style="cursor: pointer;" onclick=\'delFiles("' + fileBean.fileKey + '")\'>[删除]</span>' +
                '</div>';
            $("#speciallyFiles").after(html1);
            tip("上传成功！");
        }, onFallback: function () {
            tip("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试");
        }, onSelectError: function (file, errorCode, errorMsg) {
            switch (errorCode) {
                case -100:
                    tip("上传的文件数量已经超出系统限制的" + $('#instruction').uploadify('settings', 'queueSizeLimit') + "个文件！");
                    break;
                case -110:
                    tip("文件 [" + file.name + "] 大小超出系统限制的" + $('#instruction').uploadify('settings', 'fileSizeLimit') + "大小！");
                    break;
                case -120:
                    tip("文件 [" + file.name + "] 大小异常！");
                    break;
                case -130:
                    tip("文件 [" + file.name + "] 类型不正确！");
                    break;
            }
        }
    });
});

//二级联动
function loadCity(cityId) {
    var id = $('#province').val();
    $.post('loginWxController.do?getTerritoryCity', {id: id}, function (data) {
        data = $.parseJSON(data);
        $('#city').find('option').remove();
        var str = '<option value=""> -- 请选择 -- </option>';
        for (var i = 0; i < data.length; i++) {
            str += '<option value="' + data[i].id + '">' + data[i].territoryName + '</option>';
        }
        $('#city').append(str);
        if (cityId != '') {
            $('#city').val(cityId);
        }
    });
}

/*删除服务单附件*/
function delFile(fileId, type) {
    var flag = true;
    $.ajax({
        url: "cbsServiceController.do?delFile",
        data: {
            "id": fileId
        },
        cache: false,
        dataType: 'json',
        type: 'POST',
        async: false,
        success: function (data) {
            if (!data.success) {
                flag = false;
                tip(data.msg);
            } else {
                tip(data.msg);
                //隐藏标签
                if (type == 'a') {
                    $("#fileIda").remove();
                }
                if (type == 'b') {
                    $("#fileIdb").remove();
                }

            }
        }
    });
}

/*删除服务单附件*/
function delFiles(fileId) {
    var flag = true;
    $.ajax({
        url: "cbsServiceController.do?delFile",
        data: {
            "id": fileId
        },
        cache: false,
        dataType: 'json',
        type: 'POST',
        async: false,
        success: function (data) {
            if (!data.success) {
                flag = false;
            } else {
                $("#attach_" + fileId).remove();
            }
            top.window.tip(data.msg);
        }
    });
}

function getDate() {
    var parDate = {};
    parDate.phone = $("#phone").val(); //联系人电话
    parDate.email = $("#email").val();
    parDate.contactName = $("#contactName").val();
    parDate.qq = "";
    if ($("#qq").val() != "") {
        parDate.qq = $("#qq").val();
    }
    parDate.sn = $("#sn").val(); //设备序列号
    parDate.topItemSn = $("#topItemSn").text();//设备机型
    parDate.snServer = $("#snServer").val(); //服务器序列号
    parDate.topItemSnServer = $("#topItemSnServer").text(); //服务器机型
    parDate.province = $("#province").val(); // 省
    parDate.city = $("#city").val(); //市
    parDate.zyCinemaAddress = $("#zyCinemaAddress").val(); // 影院地址
    parDate.zyCinemaName = $("#zyCinemaName").val(); //影院名称
    parDate.typename = $("#typename").val();//院线
    parDate.client = $("#client").val();
    parDate.sourceType = $("#sourceType").val(); //委托方
    /*服务来源*/
    parDate.errorCode = "";
    $("[id^=errorCode_]").each(function () { //故障代码
        if (this.value != '' && this.value != null) {
            parDate.errorCode += this.value + ",";
        }
    });
    var errorphone = "";
    $('input[id="fileIdas"]').each(function () {
        errorphone += $(this).val() + ',';
    });
    parDate.errorphone = errorphone; //故障照片id

    var speciallyFile = "";
    $('input[id="fileIdbs"]').each(function () {
        speciallyFile += $(this).val() + ',';
    });
    parDate.speciallyFile = speciallyFile;//特批文件id
    parDate.description = $("#description").val();
    /*服务描述*/
    parDate.level = $("#levels").val(); //级别
    parDate.serviceType1 = $("#serviceType1").val(); //服务一级类型
    parDate.serviceType2 = $("#serviceType2").val(); //服务二级类型，获取二级类型的id
    parDate._serviceType2 = $("#serviceType2>option:selected").text(); // 获取二级类型的name。如果分类为故障复现，必须为子单，否则不能创单。
    parDate.errorType1 = $("#errorType1").val(); //故障分类
    parDate.errorType2 = $("#errorType2").val(); //故障分类
    parDate.equipmentErrorType1 = $("#equipmentErrorType1").val(); //关键备件故障
    parDate.equipmentErrorType2 = $("#equipmentErrorType2").val(); //关键备件故障
    parDate.judge400 = $("#judge400").val(); //400预判断
    parDate.specialCase = "";
    $("input:checkbox[name='specialCase']:checked").each(function () { // 特殊案例标记
        parDate.specialCase += $(this).val() + ",";
    });
    parDate.specially = "0";
    if ($("#specially").is(':checked')) {  //勾选了特批，
        parDate.specially = "1";
    }
    parDate.speciallyHD = "0";
    if ($("#speciallyHD").is(':checked')) {  //是否HD关单
        parDate.speciallyHD = "1";
    }
    //编辑页面新增的获取数据
    parDate.code = $("#code").text();
    parDate.serviceId = $("#cbserviceId").val();
    parDate.authentication = $("#authentication").val();
    /*工程师级别*/
    parDate.handledes = $("#handledes").val();
    /*400处理过程*/
    parDate.assignDes = $("#assignDes").html();
    /*派单要求*/
    parDate.serviceStatus = "1";  //服务单状态
    if ($("#status").val() != "" && null != $("#status").val()) {
        parDate.serviceStatus = $("#status").val();
    }

    return parDate;
}

/*判断服务单一级是否是咨询，true代表不是咨询单*/
function findServiceType1(serviceType1) {
    var rst = false;
    $.ajax({
        url: "cbsServiceController.do?getServiceType",
        data: {
            "serviceType1": serviceType1
        },
        cache: false,
        async: false,
        dataType: 'json',
        type: 'POST',
        success: function (data) {
            rst = data.success;
        }
    });

    return rst;
}






